<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>(洪研)最新材料价格表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" type="text/css" href="/general/guojigang/public/static/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="/general/guojigang/public/static/layui/css/customer.css">
</head>
<body>
    <div id="inventory_table" style="display: none;">
        名称：
        <div class="layui-inline">
          <input class="layui-input" name="item_name" id="search_item_name" autocomplete="off">
        </div>
        存货编码：
        <div class="layui-inline">
          <input class="layui-input" name="code" id="search_code" autocomplete="off">
        </div>
        规格型号:
        <div class="layui-inline">
            <input class="layui-input" name="search_model_no" id="search_model_no" autocomplete="off">
        </div>
        <button class="layui-btn layui-btn-sm" id="hy_search">搜索</button>
        <table id="inventory_list" lay-filter="user"></table>
    </div>
<div class="layui-fluid" id="LAY-component-grid-list">
    <div class="layui-row" id="popSearchRoleTest">
        <div class="layui-col-md11">
            <form class="layui-form" lay-filter="test" style = "margin-top: 20px;">
                <div class="layui-form-item">
                    <label class="layui-form-label">存货编码</label>
                    <div class="layui-input-block">
                        <input type="text" name="code" id="zjbm" autocomplete="off" class="layui-input" required  lay-verify="required" placeholder="请输入存货编码" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <input id="memo" name="memo" class="layui-input"></input>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">采购员</label>
                    <div class="layui-input-block">
                        <input id="buyer" name="buyer" class="layui-input"></input>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">名称</label>
                    <div class="layui-input-block">
                        <input type="text" id="item_name" name="item_name" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">规格型号</label>
                    <div class="layui-input-block">
                        <input type="text" id="model_no" name="model_no" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">单位</label>
                    <div class="layui-input-block">
                        <input type="text" id="unit" name="unit" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">币种</label>
                    <div class="layui-input-block">
                        <select name="currency_type" id="currency_type" lay-filter="currency_type">
                            <option value="">请选择</option>
                            <option value="人民币">人民币</option>
                            <option value="美元">美元</option>
                            <option value="欧元">欧元</option>
                            <option value="日币">日币</option>
                            <option value="英镑">英镑</option>
                            <option value="澳元">澳元</option>
                            <option value="瑞士法郎">瑞士法郎</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">含税价格</label>
                    <div class="layui-input-block">
                        <input type="text" id="price_with_tax" name="price_with_tax" class="layui-input" required lay-verify="required" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">本币价格</label>
                    <div class="layui-input-block">
                        <input type="text" id="local_currency" name="local_currency" class="layui-input" lay-verify="number">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">不含税价格</label>
                    <div class="layui-input-block">
                        <input type="text" id="price_without_tax" name="price_without_tax" class="layui-input" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" lay-submit="" lay-filter="add-hong-yan" class="layui-btn layui-btn-normal">新增</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script src="/general/guojigang/public/static/layui/layui.js" charset="utf-8"></script>
<script src="/general/guojigang/public/static/layui/goodsCode/index.js?v=1" charset="utf-8"></script>
<script src="/general/guojigang/public/static/layui/jquery.min.js"></script>
<script>


    // $("#currency_type").on("change", function(){
    //     $("#price_with_tax").val("");
    //     $("#local_currency").val("");
    //     $("#price_without_tax").val("");
    // })
    $("#price_with_tax").blur(function(){
        if ($("#currency_type").val() == "") {
            layer.alert("请先选择币种");
            $(this).val("");
            return false;
        }
        if ($("#currency_type").val() == "人民币") {
            let local_currency = ($(this).val() / 1.13).toFixed(2);
            $("#local_currency").val(local_currency);
            $("#price_without_tax").val(local_currency);
        } else if ($("#currency_type").val() == "美元" || $("#currency_type").val() == "欧元" || $("#currency_type").val() == "日币") {
            let local_currency = $(this).val();
            $.ajax({
                type: "GET",
                url:  "/general/guojigang/public/index/index/ajaxFindExchangeRate?name=" + $("#currency_type").val(),
                success: function(returnData){
                    let exchange_rate = parseFloat(returnData.data.nflat);
                    let local_currency1 = (local_currency * 1.13 * exchange_rate).toFixed(2);
                    let price_without_tax = (local_currency * exchange_rate).toFixed(2);
                    $("#local_currency").val(local_currency1);
                    $("#price_without_tax").val(price_without_tax); 
                }
            })
        }
    })
</script>
</html>